<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.bootcdn.net/ajax/libs/Mock.js/1.0.0/mock-min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="./mock.js"></script>
    <title>Mock</title>
</head>
<body>

<button id="btn">点击获取数据</button>

<script>

    const $axios = (url='', method = 'get', params = {}) => {
        return new Promise((resolve, reject) => {
            axios({
                url,
                method,
                baseURL: '/admin',
                data: params
            }).then(res => {
                resolve(res.data)
            })
        })

    }

    // mockjs
    // axios
    btn.addEventListener('click', () => {
        $axios('/user', 'get').then(res => {
            console.log("🍓 数据", res)
        })
    })

</script>
</body>
</html>